  /**
    * 面板管理类
    * by dily
    * (c) copyright false,0,0,2014 - 2035
    * All Rights Reserved. 
    * 面板的管理类
    */
module PanelManager {

    var gameStartPanel:GameStartPanel;
    var gamePanel:GamePanel;
    var gameOverPanel:GameOverPanel;
    var setPanel:SetPanel;
    var upgradePanel:UpgradePanel;
	
	// 初始化所有面板
	export function initPanel():void{
		var _width=document.documentElement.clientWidth;
    	var _height=document.documentElement.clientHeight;
    	if(_width < _height){
    		GlobalData.initIsVertical = true;
    	}
        
        Global.addEventListener(MainNotify.openStartPanelNotify,this.openStartPanel,this);
        Global.addEventListener(MainNotify.closeStartPanelNotify,this.closeStartPanel,this);

        Global.addEventListener(MainNotify.openGamePanelNotify,this.openGamePanel,this);
        Global.addEventListener(MainNotify.closeGamePanelNotify,this.closeGamePanel,this);

        Global.addEventListener(MainNotify.openGameOverPanelNotify,this.openGameOverPanel,this);
        Global.addEventListener(MainNotify.closeGameOverPanelNotify,this.closeGameOverPanel,this);
		
        Global.addEventListener(MainNotify.openSetPanelNotify,this.openSetPanel,this);
        Global.addEventListener(MainNotify.closeSetPanelNotify,this.closeSetPanel,this);
		
        Global.addEventListener(MainNotify.openUpgradePanelNotify,this.openUpgradePanel,this);
        Global.addEventListener(MainNotify.closeUpgradePanelNotify,this.closeUpgradePanel,this);

	} 

	// 打开开始界面
	export function openStartPanel():void{
		if(this.gamePanel == null){
			this.gamePanel = new GamePanel();
			PopUpManager.addPopUp(this.gamePanel,false,0,0,0);
		}
		if(this.gameStartPanel == null){
			this.gameStartPanel = new GameStartPanel();
			AlertPopUpManager.addPopUp(this.gameStartPanel,true,0,0,0);
		}
	}
	
	// 关闭开始界面
	export function closeStartPanel():void{ 
		if(this.gameStartPanel != null){
			AlertPopUpManager.removePopUp(this.gameStartPanel,1);
			this.gameStartPanel = null;
		}
	}

	// 打开游戏界面
	export function openGamePanel():void{ 
		if(this.gamePanel == null){
			this.gamePanel = new GamePanel();
			PopUpManager.addPopUp(this.gamePanel,true,0,0,3);
		}
	} 
	// 关闭游戏界面
	export function closeGamePanel():void{ 
		if(this.gamePanel != null){
			PopUpManager.removePopUp(this.gamePanel,3);
			this.gamePanel = null;
		}
	}
	
	// 打开结束界面
	export function openGameOverPanel():void{ 
		if(this.gameOverPanel == null){
			this.gameOverPanel = new GameOverPanel();
            AlertPopUpManager.addPopUp(this.gameOverPanel,true,0,0,1);
		}
	}
	// 关闭结束界面
	export function closeGameOverPanel():void{ 
		if(this.gameOverPanel != null){
            AlertPopUpManager.removePopUp(this.gameOverPanel,1);
			this.gameOverPanel = null;
		}
	}
	
	// 打开设置界面
	export function openSetPanel():void{ 
    	if(this.setPanel == null){
        	this.setPanel = new SetPanel();
        	AlertPopUpManager.addPopUp(this.setPanel,true,0,0,1);
    	}
	}
	// 关闭设置界面
	export function closeSetPanel():void{ 
		if(this.setPanel != null){
			AlertPopUpManager.removePopUp(this.setPanel,1);
			this.setPanel = null;
		}
	}
	
	// 打开升级界面
	export function openUpgradePanel():void{ 
    	if(this.upgradePanel == null){
        	this.upgradePanel = new UpgradePanel();
        	AlertPopUpManager.addPopUp(this.upgradePanel,true,0,0,1);
    	}
	}
	// 关闭升级界面
	export function closeUpgradePanel():void{ 
		if(this.upgradePanel != null){
			AlertPopUpManager.removePopUp(this.upgradePanel,1);
			this.upgradePanel = null;
		}
	}
	
	
}


